/*
 * =====================================================================================
 *
 *       FileName:  testhsv.cpp
 *
 *    Description:  This file testing the RGB --> HSV color covertor in opencv
 *
 *        Version:  1.0
 *        Created:  07/08/2010 11:51:06 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Jing (gk), race604@gmail.com
 *        Company:  BUPT, Beijing
 *
 * =====================================================================================
 */


#include	<iostream>
#include	<cv.h>
#include	<cxcore.h>
#include	"highgui.h"
#include	<stdlib.h>

using namespace std;



/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  main
 *  Description:  
 * =====================================================================================
 */
int main ( int argc, char *argv[] )
{
	char* videoFile = "/home/jing/Videos/test_1_v.avi";
	CvCapture *capture = NULL;
	IplImage* curFrame = NULL;
	IplImage* hsvImg = NULL;

	if ((capture = cvCaptureFromFile(videoFile)) == NULL)
	{
		cout << "Can't open this video:" << videoFile << endl;
		return -1;
	}

	curFrame = cvQueryFrame(capture);

	hsvImg = cvCreateImage(cvSize(curFrame->width, curFrame->height), 8, 3);

	cvNamedWindow("video", 1);
	cvNamedWindow("HSV", 1);

	while (curFrame = cvQueryFrame(capture))
	{
		//cvCvtColor(curFrame, hsvImg, CV_RGB2HSV);
		cvCvtColor(curFrame, hsvImg, CV_RGB2YCrCb);
		
		cvShowImage("video", curFrame);
		cvShowImage("HSV", hsvImg);

		int key;

		if (cvWaitKey(0)=='q')
			break;

	}

	
	return EXIT_SUCCESS;
}				/* ----------  end of function main  ---------- */

